package src.greed;

import java.util.Arrays;

public class no455 {//分发饼干

    public int findContentChildren(int[] g, int[] s) {
        Arrays.sort(g);
        Arrays.sort(s);
        int count = 0;
        int i = g.length - 1, j = s.length - 1;  // i 遍历孩子，j 遍历饼干
        while (i >= 0 && j >= 0) {
            if (s[j] >= g[i]) {
                count++;
                i--;
                j--;
            }else {
                i--;  //当饼干小于当前孩子时，让孩子指针--，胃口变小
            }

        }
        return count;
    }


}
